package com.alibaba.algo.entity.user;

import com.alibaba.algo.cooperation.usercomponent.vo.res.user.ActionInfo;
import com.alibaba.algo.core.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

/**
 * 类SysResource.java的实现描述：资源 entity
 *
 * @author nieganggang 2021-03-12 16:08:17
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class SysResource extends BaseEntity {

    private Long resourceId;
    /**
     * 资源编码
     */
    private String resourceCode;

    /**
     * 资源名称
     */
    private String resourceName;

    private Long resourceType;

    private Long parentId;

    private String path;

    private String appCode;

    /**
     * 左侧菜单栏图标
     */
    private String iconClassName;

    /**
     * 菜单标志位：0-用户组件菜单；1-其他系统菜单；
     */
    private Integer menuFlag;

    /**
     * 排序字段，升序排列，默认值为0
     */
    private Long sort;
    /**
     * 关联动作集合
     */
    private Set<ActionInfo> actionInfoList;

    /**
     * 子资源列表
     */
    private List<SysResource> childResourceList;

    private List<Long> ResourceIdList;

    private List<Integer> ResourceTypeList;

    private Long roleId;

    public void addAction(ActionInfo info){
        actionInfoList.add(info);
    }

    public void addChild(SysResource child){ childResourceList.add(child);}

    @Override
    public String toString() {
        return "SysResource{" +
                "resourceId=" + resourceId +
                ", resourceCode='" + resourceCode + '\'' +
                ", resourceName='" + resourceName + '\'' +
                ", resourceType=" + resourceType +
                ", parentId=" + parentId +
                ", path='" + path + '\'' +
                ", iconClassName='" + iconClassName + '\'' +
                ", menuFlag=" + menuFlag +
                ", sort=" + sort +
                ", actionInfoList=" + actionInfoList +
                ", childResourceList=" + childResourceList +
                ", ResourceIdList=" + ResourceIdList +
                ", ResourceTypeList=" + ResourceTypeList +
                ", roleId=" + roleId +
                '}';
    }

    public SysResource() {
        super();
        this.actionInfoList=new HashSet<>();
        this.childResourceList=new LinkedList<>();
    }

    /**
     * 是否含有下级组织
     */
    private Boolean hasChild;

    private Boolean isLink;
}
